﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Visifire.Gauges;

namespace CPPEI.Coolzon.UI.DataPartLib
{
    /// <summary>
    /// DataGaugeCircularScale.xaml 的交互逻辑
    /// </summary>
    [System.ComponentModel.DisplayName("多值仪表盘")]
    [XPartIcon("pack://application:,,,/CPPEI.Coolzon.UI.DataPartLib;component/Images/PartIcons/多值仪表盘.png")]
    public partial class DataGaugeCircularScale : DataGaugeBase
    {
        public DataGaugeCircularScale()
        {
            IsMajorTicksEnabled = true;
            IsMinorTicksEnabled = true;
            IsCircularScaleLabelsEnabled = true;
            CircularLogarithmBase = 10;
            InitializeComponent();
        }

        protected override Gauge GetGauge()
        {
            return _ctlGauge;
        }

        protected override void OnApplyXProperty()
        {
            base.OnApplyXProperty();

            Gauge gauge = GetGauge();
            if(gauge != null)
            {
                gauge.CircularScales.Clear();
                CircularScale circularScale = new CircularScale();
                SetCircularScale(circularScale);
                circularScale.MajorTicks = GetMajorTicks();
                circularScale.MinorTicks = GetMinorTicks();
                circularScale.ScaleLabels = GetScaleLabels();
                gauge.CircularScales.Add(circularScale);
            }
        }

        internal override IndicatorTypes GetIndicatorType(string dataSeriesName)
        {
            if (IndicatorsType != null && IndicatorsType.ContainsKey(dataSeriesName))
            {
                switch (IndicatorsType[dataSeriesName].ToUpper())
                {
                    case "NEEDLE": return IndicatorTypes.Needle;
                    case "BAR": return IndicatorTypes.Bar;
                    case "MARKER": return IndicatorTypes.Marker;
                }
            }
            return IndicatorTypes.Needle;
        }
    }
}
